import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../layout/index.vue'

Vue.use(VueRouter)

export const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    hidden: true,
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/login.vue')
  },
  {
    path: '',
    component: Layout,
    hidden: false,
    redirect: '/index',
    meta: {
      title: 'layout',
      icon: 'dashboard'
    },
    children: [{
      path: '/index',
      component: () => import('../views/index.vue'),
      name: 'Index',
      meta: {
        title: '首页',
        icon: 'dashboard',
        affix: true
      }
    }]
  }
  /* {
    path: '/index',
    component: () => import('../views/index.vue'),
    name: 'Index',
    meta: {
      title: '首页',
      icon: 'dashboard'
    }
  } */
]

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function (location) {
  return routerPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes: constantRoutes
})

export default router
